﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="IndexTrack.aspx.cs" Inherits="MusicSite.Views.Content.Track.IndexTrack" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript" src="../../../Content/scripts/jquery-1.3.1.js" ></script>
<script type="text/javascript" src="../../../Content/scripts/SiteScripts.js"></script>
<form id="formTrack" runat="server">
<div>
    <h2>All Tracks<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            DataObjectTypeName="Model.Entities.TrackDetails" DeleteMethod="DeleteTrack" 
            InsertMethod="InsertTrack" SelectMethod="GetTracksByName" 
            TypeName="Model.TrackProvider" UpdateMethod="UpdateTrack">
        <DeleteParameters>
            <asp:Parameter Name="trackId" Type="Int32" />
        </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="Filtr" Name="trackName" PropertyName="Text" 
                Type="String" />
        </SelectParameters>
        </asp:ObjectDataSource>
    </h2>
</div>
<div>
    <p>
        <asp:Label ID="ErrorName" CssClass="error" runat="server" Text="***Enter track's name please!"></asp:Label>
    </p>
    <p>
        <asp:Label ID="ErrorAlbName" CssClass="error" runat="server" Text="***Enter album's name please!"></asp:Label>
    </p>
</div>
<div>
    <fieldset>
        <legend>Search</legend>
        <table>
            <tr>
                <td>Track's name:</td>
                <td><asp:TextBox ID="Filtr" runat="server"></asp:TextBox></td>
            </tr>
        </table>
        <input type="submit" value="Search" />
    </fieldset>
</div>
<div>    
    <p>
        <asp:GridView ID="GridViewTrack" runat="server" CssClass="index" 
            AutoGenerateColumns="False" DataKeyNames="TrackId"
            DataSourceID="ObjectDataSource1" AllowPaging="True" 
            onrowupdating="GridViewTrack_RowUpdating">
            <Columns>
                <asp:HyperLinkField Text="Edit" DataNavigateUrlFields="TrackId" HeaderStyle-Width="30px"
                    DataNavigateUrlFormatString="~/Views/Content/Track/EditTrack.aspx?trackId={0}"/>
                <asp:BoundField DataField="TrackId" HeaderText="TrackId" Visible="false" ReadOnly="true" />
                <asp:TemplateField HeaderText="Album" HeaderStyle-Width="250px" SortExpression="AlbumName">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="ObjectDataSource2" DataTextField="AlbumName" 
                            DataValueField="AlbumId" SelectedValue='<%# Bind("AlbumID") %>'
                            AppendDataBoundItems="true">
                            <asp:ListItem Value=""></asp:ListItem>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                            SelectMethod="GetAlbums" TypeName="Model.AlbumProvider">
                        </asp:ObjectDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server"
                        Text='<%# Bind("AlbumName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="TrackName" HeaderText="Track name" />
                <asp:BoundField DataField="TimeTrack" HeaderText="Time" HeaderStyle-Width="50px"
                    DataFormatString="{0:mm:ss}"/>
                <asp:TemplateField HeaderText="Rating" HeaderStyle-Width="100px" >
                    <EditItemTemplate>
                    <asp:HiddenField ID="rate" runat="server" Value='<%# Bind("Rating")%>'/>
                        <ul class="star-rating">
                            <li onclick="starRating(1, this)">
                                <asp:HyperLink ID="hyperlink1" runat="server" CssClass="one-star">1</asp:HyperLink>
                            </li>
                            <li onclick="starRating(2, this)">
                                <asp:HyperLink ID="hyperlink2" runat="server" CssClass="two-stars">2</asp:HyperLink>
                            </li>
                            <li onclick="starRating(3, this)">
                                <asp:HyperLink ID="hyperlink3" runat="server" CssClass="three-stars">3</asp:HyperLink>
                            </li>
                            <li onclick="starRating(4, this)">
                                <asp:HyperLink ID="hyperlink4" runat="server" CssClass="four-stars">4</asp:HyperLink>
                            </li>
                            <li onclick="starRating(5, this)">
                                <asp:HyperLink ID="hyperlink5" runat="server" CssClass="five-stars">5</asp:HyperLink>
                            </li>
                        </ul>
                    </EditItemTemplate>
                    <ItemTemplate>
                    <asp:HiddenField ID="rate1" runat="server" Value='<%# Bind("Rating")%>'/>
                        <ul class="star-rating" onload="initRating(this)">
                            <li><a>1</a></li>
                            <li><a>2</a></li>
                            <li><a>3</a></li>
                            <li><a>4</a></li>
                            <li><a>5</a></li>
                        </ul>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </p>
</div>
<p>
    <asp:HyperLink ID="hyperLink1" runat="server" Text="Create new track" 
                   NavigateUrl="~/Views/Content/Track/EditTrack.aspx" >
    </asp:HyperLink>
</p>
</form>
<script type="text/javascript">
var lists = document.getElementsByTagName('UL');
for(var i in lists)
{
initRating(lists[i]);
}
</script>
</asp:Content>

